def read_file(file_path):
    """读取文件并返回文件中的名单列表"""
    with open(file_path, 'r', encoding='utf-8') as file:
        names = file.read().splitlines()
    return names

def find_absent_students(today_attendance, class_list):
    """找出没来的人的名单"""
    absent_students = list(set(class_list) - set(today_attendance))
    return absent_students

def write_file(file_path, content):
    """将名单写入文件"""
    with open(file_path, 'w', encoding='utf-8') as file:
        for name in content:
            file.write(f"{name}\n")

def main():
    today_attendance_file = '卓越班-大三-1115.txt'
    class_list_file = '卓越班-大三-全名单.txt'
    absent_list_file = 'absent_students.txt'

    today_attendance = read_file(today_attendance_file)
    class_list = read_file(class_list_file)

    absent_students = find_absent_students(today_attendance, class_list)

    write_file(absent_list_file, absent_students)

    print(f"没来的人的名单已写入 {absent_list_file}")

if __name__ == "__main__":
    main()